﻿using System;
using StackExchange.Redis;

namespace TdxHq.Common
{
    public class RedisUtils
    {
        private static readonly object Lock = new object();

        public readonly ConnectionMultiplexer HqRedis;

        private static volatile RedisUtils _instance;

        private RedisUtils()
        {
//#if DEBUG
//            HqRedis = ConnectionMultiplexer.Connect("172.19.62.234:6379,password=gs_rdpasswd");
//            Console.WriteLine("--------------------------------DEBUG模式--------------------------------------");
//#else
            HqRedis = ConnectionMultiplexer.Connect("127.0.0.1:6379,password=gs_redis_password");
//#endif
        }

        public static RedisUtils GetInstance()
        {
            if (null != _instance) return _instance;
            
            lock (Lock)
            {
                if (null == _instance)
                    _instance = new RedisUtils();
            }
            
            return _instance;
        }
    }
}